#include "stdafx.h"
#include "QueObjU8.h"
#include "U8Queue.h"


U8Queue::U8Queue()
{
	m_pFront = 0;
	m_pBack = 0;
	count = 0;
}


U8Queue::~U8Queue()
{
	while (m_pFront != 0) {
		Pop();
	}
}


void U8Queue::Push(unsigned char data)
{
	QueObjU8* obj = new QueObjU8(data);

	if (m_pFront == 0) {
		m_pFront = obj;
		m_pBack = obj;
	}
	else {
		m_pBack->next = obj;
		m_pBack = obj;
	}

	count++;
}


unsigned char U8Queue::Pop()
{
	if (m_pFront == 0)return 0;

	QueObjU8* tmp = m_pFront;
	unsigned char ret = m_pFront->m_data;

	m_pFront = m_pFront->next;

	delete tmp;
	count--;

	return ret;
}


int U8Queue::Size()
{
	return count;
}


